//////#include<iostream>
//////using namespace std;
//////void dfs(int n, char a, char b, char c)
//////{
//////	if (n == 0) return;
//////	dfs(n - 1, a, c, b);
//////	cout << a << "->" << b << endl;
//////}
//////int main()
//////{
//////	int n;char a,b,c;cin >> n >> a >> b >> c;
//////	dfs(n, a, b, c);
//////	return 0;
//////}
////#include<iostream>
////using namespace std;
////void dfs(int n, char a, char b, char c)
////{
////	if (n == 0) return;
////	dfs(n - 1, a, c, b);
////	cout << a << "->" << n << "->" << b << endl;
////	dfs(n - 1, a, b, c);
////}
////int main()
////{
////	int n;char a, b, c;cin >> n >> a >> b >> c;
////	dfs(n, a, b, c);
////	return 0;
////}
//#include<iostream>
//using namespace std;
//void dfs(int n, char x, char y, char z)
//{
//	if (n == 0) return;
//	dfs(n - 1, x, z, y);
//	cout << x << "->" << n << "->" << z << endl;
//	dfs(n - 1, y, x, z);
//}
//int main()
//{
//	int n ;char x, y, z;cin >> n >> x >> y >> z;
//	dfs(n, x, z, y);
//	return 0;
//}

#include<iostream>
using namespace std;
void dfs(int n, char x, char z, char y)
{
	if (n == 0) return;
	dfs(n - 1, x, y, z);
	cout << x << "->"<< n << "->"<< y <<endl;
	dfs(n - 1, z, x, y);
}
int main()
{
	int n;char x,y,z;cin >> n >> x >> y >> z;
	dfs(n, x, z, y);
	return 0;
}
